<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
    <script>
            /**
       * @param {number[]} nums
       * @return {number[][]}
       */
      var subsets = function(nums) {
          let  res=[]
          let path=[]
          let sortNums=nums.sort((a,b)=>{return a-b})
          function backtrack(start){
            res.push([...path])
            for(let i=start;i<sortNums.length;i++){
               if(nums[i]===nums[i-1]){
                 continue
               }
                let num=sortNums[i]
                path.push(num)
                backtrack(i+1)
                path.pop()
            }
          }
          backtrack(0)
          return res
      };
      console.log(subsets([1,2,3]));
    </script>
</body>
</html>